/*
 * Copyright (c) 2013 Hai Bison
 *
 * See the file LICENSE at the root directory of this project for copying
 * permission.
 */

package com.haibison.android.logs.providers.log;

import android.content.ContentResolver;
import android.content.Context;
import android.net.Uri;
import android.util.Log;

import com.haibison.android.logs.Env;
import com.haibison.android.logs.providers.BaseCols;

/**
 * Contract for {@link LogProvider}.
 * 
 * @author Hai Bison
 * @since v1.0 beta
 */
public class LogContract implements BaseCols {

    public static final String AUTHORITY = Env.LIB_NAME + ".log";

    public static final String TABLE_NAME = "logs";

    public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.group.pals.android.lib.logs.provider.log";

    public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.group.pals.android.lib.logs.provider.log";

    public static final int URI_CONTENT = 1;

    public static final int URI_CONTENT_ITEM = 2;

    /**
     * Gets the authority of this provider.
     * 
     * @param context
     *            the context.
     * @return the authority.
     */
    public static final String getAuthority(Context context) {
        return context.getPackageName() + "." + AUTHORITY;
    }// getAuthority()

    /**
     * The {@code content://} style URI for this table.
     */
    public static final Uri genContentUri(Context context) {
        return Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
                + getAuthority(context));
    }// genContentUri()

    /**
     * The content URI base for a single log item. Callers must append a numeric
     * log ID to this URI to retrieve a log item.
     */
    public static final Uri genContentIdUriBase(Context context) {
        return Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
                + getAuthority(context) + "/");
    }// genContentIdUriBase()

    /*
     * COLUMNS
     */

    /**
     * The level. One of {@code LEVEL_*}.
     * <p/>
     * Type: {@link Integer}.
     */
    public static final String COLUMN_LEVEL = "level";

    /**
     * The tag.
     * <p/>
     * Type: {@link String}.
     */
    public static final String COLUMN_TAG = "tag";

    /**
     * The log message.
     * <p/>
     * Type: {@link String}.
     */
    public static final String COLUMN_MESSAGE = "message";

    /**
     * The stack tracce of a {@link Throwable}.
     * <p/>
     * Type: {@link String}.
     */
    public static final String COLUMN_THROWABLE = "throwable";

    public static final String DEFAULT_SORT_ORDER = _DATE_MODIFIED + " DESC";

    /*
     * LOG LEVELS
     */

    /**
     * @see Log#ASSERT
     */
    public static final int LEVEL_ASSERT = Log.ASSERT;

    /**
     * @see Log#DEBUG
     */
    public static final int LEVEL_DEBUG = Log.DEBUG;

    /**
     * @see Log#ERROR
     */
    public static final int LEVEL_ERROR = Log.ERROR;

    /**
     * @see Log#INFO
     */
    public static final int LEVEL_INFO = Log.INFO;

    /**
     * @see Log#VERBOSE
     */
    public static final int LEVEL_VERBOSE = Log.VERBOSE;

    /**
     * @see Log#WARN
     */
    public static final int LEVEL_WARN = Log.WARN;

    /**
     * This is singleton class.
     */
    private LogContract() {
    }// LogContract()

}
